/**
 *  @file SQLiteDatabase.h
 */
#ifndef _SQLITEDATABASE_H_
#define _SQLITEDATABASE_H_

#include "../../common/BaseObject.h"
#include "../../text/CFString.h"

namespace cppflib
{

namespace database
{

namespace sqlite
{

class SQLiteCommand;
class SQLiteBlobIO;

/**
 *  SQLite database connection class
 */
class _DLLAPI SQLiteDatabase : public BaseObject
{
private:
    CFString dbPath;
    ptrany_t pDbConn;

private:
    ptrany_t GetDbConn();
    
public:
    SQLiteDatabase(void);
    virtual ~SQLiteDatabase(void);

    bool Open(const CFString &dbPath);
    void Close();
    void GetDbPath(CFString &path);
    void GetDbLastError(CFString &err);
    i64_t GetLastInsertRowID();

    PUBLIC void GetSQLiteVersion(CFString &ver);

    typedef enum
    {
       ROWID,          ///< hidden column of every SQLite table
       MAINDB,         ///< main database name
       TEMPDB,         ///< database name for temp tables
    } sqlitenames_t;

    PUBLIC pcwstr_t GetConstName(sqlitenames_t n);
    PUBLIC const char * GetConstNameA(sqlitenames_t n);
    
    friend class SQLiteCommand;
    friend class SQLiteBlobIO;
};

} // end of namespace sqlite

} // end of namespace database

} // end of namespace cppflib


#endif
